package ruralmanagementsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import ruralmanagementsystem.dto.CommodityDTO;
import ruralmanagementsystem.pojo.Commodity;
import ruralmanagementsystem.vo.CommodityVO;

import java.util.List;

@Mapper
public interface CommodityMapper {
    //根据id查询商品信息
    @Select("select * from rural.commodity_tb where id = #{id}")
    Commodity getCommodityById(Integer id);

    //分页查询所有商品
    Page<CommodityVO> paginationQuery(CommodityDTO commodityDTO);

    //根据id删除商品
    @Delete("delete from rural.commodity_tb where id = #{id}")
    void deleteCommodityById(Integer id);

    //新增商品
    @Insert("insert into rural.commodity_tb values" +
            "(null, #{household}, #{name}, #{describe}, #{parameter}, #{img1}, #{img2}, #{price})")
    void insertCommodity(Commodity commodity);
}
